<template>
  <div class="person">
    <h2>Person组件</h2>
    <h3>姓名：{{ name }}</h3>
    <h3>年龄：{{ age }}</h3>
    <h3>座驾：{{ car }}</h3>
    <h3>父亲给我的x是：{{ x }}</h3>
    <button @click="changeName">改名字</button>
    <button @click="changeAge">改年龄</button>
    <button @click="changeCar">改座驾</button>
    <button @click="changeCarColor">改座驾的颜色</button>
  </div>
</template>

<script>
  // 此处写脚本
  export default {
    name:'Person',
    // 接收外部传递过来的props
    props:['name','age','car','x'],
    // “自家的”数据
    data() {
      return {
        x:1
      }
    },
    methods:{
      changeName(){
        this.name = '静香'
      },
      changeAge(){
        this.age = 90
      },
      changeCar(){
        this.car = {brand:'保时捷',color:'白色'}
      },
      changeCarColor(){
        this.car.color = '红色'
      }
    }
  }
</script>

<style scoped>
  /* 此处写样式 */
  .person {
    background-color: skyblue;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 10px;
  }
</style>